package com.yanyeori.webtest.config.http;

import com.yanyeori.framework.web.http.accept.HttpHeaderContextHandler;
import com.yanyeori.nacosfeign.context.AContext;
import com.yanyeori.nacosfeign.context.AContextHolder;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author chenkuan
 * @since 2021/8/2 002 18:44
 */
@Component
public class WebHttpAcceptHandler extends HttpHeaderContextHandler {

    @Override
    protected void handleContext(HttpServletRequest request, HttpServletResponse response) {
        super.handleContext(request, response);
        AContextHolder.setAContext(handleContextBean(request, AContext.class));
    }

    @Override
    protected void clearContext(HttpServletRequest request, HttpServletResponse response) {
        super.clearContext(request, response);
        AContextHolder.clear();
    }
}
